<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml" xmlns:th="http://www.thymeleaf.org" xmlns:sec="http://www.thymeleaf.org/thymeleaf-extras-springsecurity3">
<head th:replace="top::html" />
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no" name="viewport">

<body class="fixed hold-transition skin-blue">
    <div class="wrapper">
        <div th:replace="tophtml::html"></div>
        <div th:replace="left::html"></div>
        <div class="content-wrapper">
            <section class="content-header">
                <h1>
                    <span>项目匹配需求</span> 
                    <small></small>
                </h1>
                <ol class="breadcrumb">
                    <li><a th:href="@{/index}"><i class="fa fa-dashboard"></i>用户中心</a></li>
                    <li><a th:href="@{/project/showQuery}"><i class="fa fa-dashboard"></i>项目管理</a></li>
                    <li><a th:href="@{'/demand/showProjectMatchedDemand?pid='+${project.pid}}">项目匹配需求</a></li>
                </ol>
            </section>
			
            <!-- Main content -->
            <section class="content container-fluid">
                <p style="color: red;" th:text="${searchEmpty}"></p>
                <form id="from1" class="form-inline" th:action="@{/demand/searchMatchedDemand}" method="get">
                    <input type="hidden" name="pageNo" id="pageNo" />
                    <input type="hidden" name="projectId" th:value="${project.pid}" />
	                <div style="font-size: 16px;">
		              	<div class="form-group">
							<label>项目名称:</label>
							<a th:href="@{'/project/showConditionQuery?searchKeyword=R'+${project.projectNumber}}" th:text="${project.projectName}">查看详情</a>
		            		<a th:href="@{'/project/showDemandButtDetail?pid='+${project.pid}}"  style="font-weight: bolder;margin-left: 60px;">项目已匹配需求</a>
		            		<a th:unless="${#lists.isEmpty(buttedDemandIdList)}" th:href="@{'/project/downButtedDemand?projectId='+${project.pid}}"  style="font-weight: bolder;margin-left: 60px;">下载</a>
		              	</div>
		              	<br>
		               	<div class="form-group">
							<label>项目简介:</label>
							<span th:title="${project.introduction}" th:text="${not #strings.isEmpty(project.introduction)} and ${#strings.length(project.introduction)} > 20 ? ${#strings.substring(project.introduction, 0, 20)}+'...' : ${project.introduction}"></span>            			
		             	</div>
					</div>   
	                <hr style="height:1px;border:none;border-top:1px solid #a4b1c2;" /> 
                    <div class="form-group">
                        <input style="width: 500px; display: inline" type="text" class="form-control" placeholder="id或名称或关键字" name="searchKeyword" th:value="${param.searchKeyword}">
                        <button type="submit" class="btn btn-primary" style="margin-left: 40px;">搜索</button>
                        <button type="reset" style="margin-left: 40px;" class="btn btn-primary">重置</button>
                        <input type="button" class="btn btn-primary" value="返回" onclick="window.history.go(-1)" style="margin-left: 40px;">
                    </div><br>
                    <div class="form-group">
                        <label>所属领域</label>
                        <span th:each="rfd : ${researchFieldDictiontryList}">
	                        <label style="font-weight: lighter;">
	                            <input type="checkbox" name="researchField" th:value="${rfd.names}" th:text="${rfd.worth}" th:checked="${researchFieldArr != null ? #arrays.contains(researchFieldArr, rfd.names) : false}">
	                        </label>
                        </span>
                    </div>
                    <div>
                        <span class="from-group">
	                        <label>国内国外</label>
	                        <label style="font-weight: lighter;">
		                        <input type="radio" name="domesticOrForeign" id="optionsRadios1" value="0" th:checked="${domesticOrForeign == 0}"> 国内
	                        </label>
	                        <label style="font-weight: lighter;">
		                        <input type="radio" name="domesticOrForeign" id="optionsRadios2" value="1" th:checked="${domesticOrForeign == 1}"> 国外
	                        </label>
                        </span>
                        <span class="form-group form-country">
                            <select class="form-area">
                                <option value="-1">--选择国家--</option>
                                <option th:each="list:${countryDictiontryList}" th:value="${list.pid}" th:text="${list.worth}" th:selected="${list.pid eq country}"></option>
                            </select>
                        </span>
                        <span class="form-group form-area">
	                        <select class="form-area" id="provinceId">
	                            <option value="-1">--选择省--</option>
	                            <option th:each="list:${provinceDictiontryList}" th:value="${list.names}" th:text="${list.worth}" th:selected="${list.names eq province}"></option>
	                        </select>
                        </span>
                        <span class="form-group form-area">
	                        <select class="form-area" id="cityId">
	                            <option value="-1">--选择市--</option>
	                            <option th:each="list:${cityDictiontryList}" th:value="${list.names}" th:text="${list.worth}" th:selected="${list.names eq city}"></option>
	                        </select>
                        </span>
                        <span class="form-group form-area">
	                        <select class="form-area" id="areaId">
	                            <option value="-1">--选择区--</option>
	                            <option th:each="list:${areaDictiontryList}" th:value="${list.names}" th:text="${list.worth}" th:selected="${list.names eq district}"></option>
	                        </select>
                        </span>
                    </div>
                </form>
                <br>
                <div class="box">
                    <button id="dosubmit" class="btn btn-primary">匹配</button>
                    <div class="box-body">
                        <table class="table table-bordered">
                            <tbody>
                                <tr>
                                    <th><input id="all" type="checkbox" /></th>
                                    <th>需求id</th>
                                    <th>需求名称</th>
                                    <th>需求类型</th>
                                    <th>需求状态</th>
                                    <th>需求联系人</th>
                                    <th>匹配</th>
                                </tr>
                                <tr th:each="lucDem : ${pageInfo.list}" th:with="isButted=${not #lists.isEmpty(buttedDemandIdList)} and ${#lists.contains(buttedDemandIdList, lucDem.demandId)}" th:class="${isButted} ? butt-gray">
                                    <td><input type="checkbox" class="matched" th:disabled="${isButted}" th:value="'demandId='+${lucDem.demandId}+'&demandNumber='+${#strings.replace(lucDem.demandNumber, 'D', '')}+'&demandName='+${lucDem.demandName}+'&projectId='+${project.pid}+'&projectNumber='+${project.projectNumber}+'&projectName='+${project.projectName}" /></td>
                                    <td><a th:href="@{'/demand/showDetail?demandId='+${lucDem.demandId}+'&projectId='+${project.pid}}" th:text="${lucDem.demandNumber}"></a></td>
                                    <td th:text="${lucDem.demandName}">飞船材料</td>
                                    <td th:text="${lucDem.demandType}">类型</td>
                                    <td th:text="${lucDem.demandStatus}">状态</td>
                                    <td>
                                        <a th:if="${lucDem.demandContactId} and ${lucDem.demandContactId} != 'null'" th:href="@{/demand/showUpdateContact(demandContactId=${lucDem.demandContactId})}" th:text="${lucDem.demandContactName}">联系人</a>
                                    </td>
                                    <td>
                                    	<a href="javascript:void(0);" th:class="${not isButted} ? singleMatch">匹配</a>
                                    </td>
                                </tr>
                            </tbody>
                        </table>
                        <div th:replace="page1::html"></div>
                        <p style="color: red;" th:text="${demandContactIdExists}"></p>
                    </div>
                </div>
            </section>
        </div>
        <div th:replace="footer::html"></div>
        <div class="control-sidebar-bg"></div>
    </div>
    <div th:replace="bottom::html" ></div>
    <script type="text/javascript" th:inline="javascript">
        matchButt([[@{/demand/projectMatchDemand}]]);
        $("a.singleMatch").one("click", function() {
        	$(this).closest("tr").find(":checkbox").prop("checked", true);
        	matching([[@{/demand/projectMatchDemand}]]);
        });
    </script>
</body>

</html>